#include "gtest/gtest.h"

#include "DataStructure/Input/Coordinate/CORD2RData.h"
#include "DataStructure/Input/Coordinate/ICoordinate.h"

using namespace SG::DataStructure::FEM;
using SG::Algebra::Point;
using SG::Algebra::Vector3D;
using SG::DataStructure::Common::Real;
using SG::DataStructure::FEM::Cartesian2Coord;

TEST (Cartesian2CoordTest, Cartesian2CoordComputeTrans2Basic)
{
    // Input
    Point GA{ 1.0, 2.0, 3.0 };
    Point GB{ 4.0, 5.0, 6.0 };
    Point GC{ 9.0, 8.0, 7.0 };
    Real  localX = 1.0;
    Real  localY = 2.0;
    Real  localZ = 3.0;

    // Test data
    Cartesian2Coord Cartesian2;
    Cartesian2.Compute (GA, GB, GC);
    Point originTest = Cartesian2.GetOrigin ();

    // Target Data
    Point    originTarget{ 1.0, 2.0, 3.0 };
    Vector3D baseXTarget{ 0.707107, 0.0, -0.707107 };
    Vector3D baseYTarget{ -0.408248, 0.816497, -0.408248 };
    Vector3D baseZTarget{ 0.577350, 0.577350, 0.577350 };

    // Check
    ASSERT_TRUE (originTest == originTarget);
    ASSERT_TRUE (Cartesian2.GetBaseX () == baseXTarget);
    ASSERT_TRUE (Cartesian2.GetBaseY () == baseYTarget);
    ASSERT_TRUE (Cartesian2.GetBaseZ () == baseZTarget);

    // Test Data
    auto golbalCoordTest = Cartesian2.Trans2Basic (localX, localY, localZ);

    // Target data
    Point golbalCoordTarget{ 2.622661, 5.365044, 3.208447 };

    // Check
    ASSERT_TRUE (golbalCoordTest == golbalCoordTarget);
}
